<h2>DESCRIPTION</h2>

<em>v.out.ogr</em> converts GRASS vector map layer to any of the
supported <a href="http://www.gdal.org/">OGR</a> vector formats
(including OGC GeoPackage, ESRI Shapefile, SpatiaLite or GML).

<p>
OGR (Simple Features Library) is part of the
<a href="http://www.gdal.org">GDAL</a> library, so you need to
install this library to use <em>v.out.ogr</em>. 

<p>
The OGR library supports many various formats including:

<ul>
  <li><a href="http://www.gdal.org/drv_geopackage.html">OGC GeoPackage</a></li>
  <li><a href="http://www.gdal.org/drv_shapefile.html">ESRI Shapefile</a></li>
  <li><a href="http://www.gdal.org/drv_pg.html">PostGIS</a></li>
  <li><a href="http://www.gdal.org/drv_sqlite.html">SpatiaLite</a></li>
  <li><a href="http://www.gdal.org/drv_csv.html">CSV</a></li>
  <li><a href="http://www.gdal.org/drv_gml.html">GML</a></li>
  <li><a href="http://www.gdal.org/drv_kml.html">KML</a></li>
  <li><a href="http://www.gdal.org/drv_mitab.html">Mapinfo File</a></li>
  <li><a href="http://www.gdal.org/drv_tiger.html">TIGER</a></li>
  <li>... and many others</li>
</ul>

The list of supported formats is printed with the <em>-l</em> flag.

<p>
For further available other supported formats go 
<a href="https://gdal.org/drivers/vector/">here</a>.

<h2>NOTES</h2>

By default, islands will appear as holes inside surrounding areas. To
export polygons with holes into, e.g., a Esri Shapefile, and make the
holes appear as filled areas, the flag <b>-c</b> has to be used.

<p>
<em>v.out.ogr</em> exports 3D vector data as 2.5D simple features if
possible (not supported by all formats). For exporting 3D vector data
as 2D simple features, use <b>-2</b> flag.

<p>
By default, <em>v.out.ogr</em> converts GRASS vector data to single
simple features. If GRASS feature has more categories defined in the
given <b>layer</b>, then this feature is exported multiple
times. GRASS features without category are skipped by default. To
export features also without category, the <b>-c</b> flag must be
given.

<p>
When <b>-m</b> flag is given, <em>v.out.ogr</em> export GRASS vector
data as multi-features. Multi-feature is formed by GRASS features with
the same category. When <b>-c</b> flag is given, the module also
export GRASS features without category as one multi-feature. Note that
multi-features are not supported by all formats.

<p>
ESRI Shapefile export: note that due to the DBF table specifications
column names may not be longer than 10 characters.

<p>
Performance: export to SQLite based formats including OGC GeoPackage may
become faster with the environmental variable <tt>OGR_SQLITE_CACHE=1024</tt>
being set (value depends on available RAM, see
<a href="https://trac.osgeo.org/gdal/wiki/ConfigOptions#OGR_SQLITE_CACHE">OGR ConfigOptions</a>).

<h2>EXAMPLES</h2>

<h3>Export to OGC GeoPackage</h3>

Export lines from a GRASS vector map to OGC GeoPackage format:

<div class="code"><pre>
v.out.ogr input=roadsmajor type=line output=roadsmajor.gpkg
</pre></div>

<p>
Export areas from GRASS vector map to OGC GeoPackage format, converting
islands (holes) to filled polygons:

<div class="code"><pre>
v.out.ogr -c input=areas_islands type=area output=areas_islands.gpkg
</pre></div>

<p>
Export mixed geometry type GRASS vector map to OGC GeoPackage format:

<div class="code"><pre>
v.out.ogr input=generic_vector output=mixed_geometry.gpkg
</pre></div>

<h3>Export to ESRI Shapefile</h3>

Export lines from GRASS vector map to Shapefile format:

<div class="code"><pre>
v.out.ogr input=roadsmajor type=line format=ESRI_Shapefile output=lines.shp
</pre></div>

<p>
Export areas from GRASS vector map to Shapefile format, converting
islands (holes) to filled polygons:

<div class="code"><pre>
v.out.ogr -c input=areas_islands type=area format=ESRI_Shapefile output=areas_islands.shp
</pre></div>

<p>
Export 3D lines from GRASS vector map to Shapefile format:

<div class="code"><pre>
v.out.ogr input=lines_3d type=line format=ESRI_Shapefile output=lines_3d.shp lco="SHPT=ARCZ"
</pre></div>

<p>
Export 3D points (e.g., Lidar points) from GRASS vector map to Shapefile format

<div class="code"><pre>
v.out.ogr points_3d type=point format=ESRI_Shapefile output=points_3d.shp lco="SHPT=POINTZ"
</pre></div>

<p>
Export 3D faces from GRASS vector map to Shapefile format:
<div class="code"><pre>
v.out.ogr input=objects_3d type=face format=ESRI_Shapefile output=faces_3d.shp lco="SHPT=POLYGONZ"
</pre></div>

<p>
Export 3D faces from GRASS vector map to Shapefile format, automatic 3D setting:

<div class="code"><pre>
v.out.ogr input=objects_3d type=face format=ESRI_Shapefile output=faces_3d.shp"
</pre></div>

<h3>Export to GML</h3>

Export lines from GRASS vector map to GML format
 (generates '/tmp/testogr.gml' file with layer 'testogr'):

<div class="code"><pre>
v.out.ogr input=multi type=line output=/tmp/testogr.gml output_layer=testogr format=GML 
</pre></div>

<h3>Export to PostgreSQL/PostGIS</h3>

Export areas from GRASS vector map to PostGIS database:

<div class="code"><pre>
v.out.ogr input=polygons type=area output="PG:host=localhost dbname=postgis user=postgres" output_layer=polymap format=PostgreSQL
</pre></div>

<i>Note:</i> For exporting GRASS vector data to PostGIS database can
be also used <em><a href="v.out.postgis.html">v.out.postgis</a></em>
module. This module is not based on OGR library and supports beside
simple features also topological format (PostGIS Topology).

<h3>Export to KML (Google Earth)</h3>

<p>
Export faces (3D vectors) from GRASS vector map to KML format for Google Earth:

<div class="code"><pre>
v.out.ogr input=buildings_3d output=buildings_3d.kml output_layer=buildings_3d format=KML type=face
</pre></div>

<p>
Generate and export GRASS vector "asteroid" map (faces, 3D vectors) to
KML format for Google Earth:

<div class="code"><pre>
# near Raleigh (NC, USA)
g.region n=35.73952587 s=35.73279182 w=-78.68263928 e=-78.67499517

# two layers of random points
v.random -z output=random3d_a n=10 zmin=0 zmax=200
v.random -z output=random3d_b n=15 zmin=400 zmax=600

# merge into one 3D points map
v.patch input=random3d_a,random3d_b output=random3d

# generate 3D convex hull
v.hull input=random3d output="random3d_hull"

# export to KML 3D
v.out.ogr input=random3d_hull output=random3d_hull.kml format=KML type=face dsco="AltitudeMode=absolute"

# now open KML file 'random3d_hull.kml' in Google Earth or NASA WorldWind or ...
</pre></div>

<h2>REFERENCES</h2>

<ul>
<li><a href="http://www.gdal.org/">OGR vector library</a></li>
<li><a href="https://gdal.org/api/">OGR vector library C API</a>
  documentation</li>
</ul>

<h2>SEE ALSO</h2>

<em>
<a href="v.out.postgis.html">v.out.postgis</a>,
<a href="db.out.ogr.html">db.out.ogr</a>,
<a href="v.external.html">v.external</a>,
<a href="v.external.out.html">v.external.out</a>,
<a href="v.in.ogr.html">v.in.ogr</a>,
<a href="v.pack.html">v.pack</a>
</em>

<h2>AUTHORS</h2>

Radim Blazek, ITC-Irst, Trento, Italy<br>
Some contributions: Markus Neteler<br>
Multi-feature support by Martin Landa, Czech Technical University in Prague, 2013

<!--
<p>
<i>Last changed: $Date$</i>
-->

